package com.xtianzhuang.www.study2019.functions.enums;

public enum Response implements Behaviour {
	SUCCESS("成功", "0000"), FAIL("失败", "9999");

	private String message;
	private String code;

	// 构造方法
	private Response(String name, String index) {
		this.message = name;
		this.code = index;
	}

	public static String getMessage(String code) {
		for (Response res : Response.values()) {
			if (res.getCode().equals(code)) {
				return res.message;
			}
		}
		return "";
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Override
	public void print() {
		// TODO Auto-generated method stub
		System.out.println(this.code + ":" + this.message);
	}

	@Override
	public String getInfo() {
		// TODO Auto-generated method stub
		return this.name();
	}


}
